package com.sky.mapper;

import com.github.pagehelper.Page;
import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderHistoryxzsVO;
import org.apache.ibatis.annotations.Select;

public interface OrderMapper {
    //新增订单
    void insert(Orders orders);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /**
     * 根据id查询订单
     * @param id
     * @return
     */
    @Select("select * from orders where id=#{id}")
    Orders getById(Long id);

    /**
     * 根据id 查找订单
     * @param id
     * @return
     */
    @Select("select * from orders where id =#{id}")
    Orders getOrderByIdxzs(Long id);

    /**
     * 历史订单查询
     * @param userId
     * @param status
     * @return
     */
    Page<OrderHistoryxzsVO> listHistoryOrdersxzs(Long userId, Integer status);

    /**
     * 根据Id查询订单
     * @param id
     * @return
     */
    Orders getDetailsById(Integer id);

    /**
     * 统计订单状态数量
     * @param status
     */
    @Select("select count(status) from orders  where  status=#{status}")
    Integer showStatusCount(Integer status);

    /**
     * 根据路径id获取订单
     * @param id
     * @return
     */
    @Select("select * from orders where id=#{id}")
    Orders getByIdHsj(Integer id);


    //根据id 查询订单
    @Select("select * from orders where id=#{id}")
    Orders getById();

    //订单分页查询
    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);
    //根据订单id获取订单
    @Select("select * from orders where id = #{id}")
    Orders getByOrderId(Long orderId);
}
